package com.zff.rental.file;

import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.nio.file.spi.FileSystemProvider;

public class MoveFileExample {
    public static void main(String[] args) {
        FileSystemProvider provider = FileSystems.getDefault().provider();
        Path sourcePath = Paths.get("example.txt");
        Path targetPath = Paths.get("example_renamed.txt");

        try {
            provider.move(sourcePath, targetPath, StandardCopyOption.REPLACE_EXISTING);
            System.out.println("文件移动成功: " + sourcePath + " -> " + targetPath);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}